package lanqiaobeiquestion;

import java.util.Scanner;

//public class Mian5 {

//	public static void main(String[] args) {
//		Scanner scanner = new Scanner(System.in);
//		int n = scanner.nextInt();
//		int[] arr = new int[n];
//		for (int i = 0; i < n; i++) {
//			arr[i] = scanner.nextInt();
//		}
//		int k = scanner.nextInt();
//		for (int i = 0; i < n; i++) {
//			int min = Integer.MAX_VALUE;
//			for (int j = 0; j < 2 * k + 1; j++) {
//				int index = i - k + j;
//				if (index >= 0 && index < n) {
//					min = Math.min(min, arr[index]);
//				}
//			}
//			if (min != Integer.MAX_VALUE) {
//				System.out.print(min + " ");
//			}
//		}
//		scanner.close();
//	}
//}

import java.util.*;
//1:无需package
//2: 类名必须Main, 不可修改

public class Mian5 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = scanner.nextInt();
		}
		int[] temp = Arrays.copyOf(arr, n);
		Arrays.sort(temp);
		int k = scanner.nextInt();
		for (int i = 0; i < n; i++) {
			int min = Integer.MAX_VALUE;
			for (int j = 0; j < 2 * k + 1; j++) {
				int index = i - k + j;
				if (index >= 0 && index < n) {
					min = Math.min(min, arr[index]);
				}
			}
			System.out.print(min + " ");
		}
		scanner.close();
	}
}